home *** CD-ROM | disk | FTP | other *** search
- #include <graphics.h>
- #include <stdlib.h>
-
- main()
- {
- int graphdriver = DETECT, graphmode;
- int bcolor, maxcolor;
-
- /* Initialize the graphics system */
- initgraph(&graphdriver, &graphmode, "c:\\turboc");
- /* Get current background color and save it */
- bcolor = getbkcolor();
- /* Now keep switching background colors randomly */
- maxcolor = getmaxcolor();
- randomize(); /* Initialize random number generator */
- outtextxy(10,20, "Press any key to exit");
- while (!kbhit())
- {
- setbkcolor(random(maxcolor));
- delay(1000); /* Pause for 1 second */
- }
- /* Wait for 1 second, then restore previous color */
- delay(1000);
- setbkcolor(bcolor);
- delay(1000); /* Let user see the change */
- closegraph();
- }